package com.example.aidemo.config;

import java.util.function.Function;

public class MockWeatherService implements Function<MockWeatherService.Request, MockWeatherService.Response> {

	public enum Unit { C, F }
	public record Request(String location, Unit unit) {}
	public record Response(double temp, Unit unit) {}

	public Response apply(Request request) {
		//调用其他服务的远程接口,调用气象局的远程接口
		if (request.location.equals("北京")){
			return new Response(-10, Unit.C);
		}else if(request.location.equals("上海")){
			return new Response(0, Unit.C);
		}else {
			return new Response(20, Unit.C);
		}
	}
}